package com.kuaiyin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kuaiyin.entity.JmeterCaseRelation;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * JMeter测试用例关联表（存储用例与JMeter测试的映射关系） Mapper 接口
 * </p>
 *
 * @author ng
 * @since 2025-07-03
 */
public interface JmeterCaseRelationMapper extends BaseMapper<JmeterCaseRelation> {

    @Insert("insert into jmeter_case_relation(jmeter_id,plan_id,case_id,jmx_response_extract) values(#{id},#{planId},#{caseId},#{valueMap})")
    void insertJmxResponseExtract(Integer id, Long planId, String caseId, Map<Object, Object> valueMap);

    @Select("select jmx_response_extract from jmeter_case_relation where jmeter_id=#{id} and case_id=#{caseId} and plan_id=#{planId}")
    String selectJmxResponseExtract(@Param("id") Long id, @Param("caseId") Long caseId, @Param("planId") Long planId);

    @Select("select case_id,  jmx_response_extract from jmeter_case_relation where jmeter_id= #{id}")
    List<Map<String, Object>> selectResponseExtractByJmeterId(Long id);
    @Delete("delete from jmeter_case_relation where jmeter_id= #{id}")
    void deleteByJmeterId(Long id);
}
